package com.java2007.hotel.dao.impl;

import com.java2007.hotel.dao.DinnerTableDao;
import com.java2007.hotel.pojo.DinnerTable;
import com.java2007.hotel.utils.JdbcUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import javax.management.Query;
import java.sql.SQLException;
import java.util.List;
import java.util.jar.JarEntry;

/**
 * @author ghy
 * @version 1.0
 * @date 2021-01-25
 */
public class DinnerTableDaoImpl implements DinnerTableDao {
    /**
     * 根据状态查询餐桌
     *
     * @param status
     * @return
     */
    @Override
    public List<DinnerTable> findByStatus(Integer status) throws SQLException {
        QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
        String sql = "SELECT `id`,`table_name` tableName,`status`,`reservation_time` reservationTime,`create_time` createTime,`update_time` updateTime,`create_user` createUser FROM `t_dinner_table` WHERE `status` = ?";
        return runner.query(sql, new BeanListHandler<>(DinnerTable.class), status);
    }
}
